#主函数
def main():
    s = input("请输入字符串:")
    if len(s) == 0 or len(s) > 255:
        print("输入的字符串不合法")
    letter(s)
#过滤
def letter(string):
    s = list(filter(lambda char: char.isalpha(), string))
    reverse(s)
    x = enCode(s)
    print("密文为:")
    y = ''.join(x)
    print(y)
    
#翻转
def reverse(sd):
    return sd.reverse()

#加密
def enCode(s):
    k = 4
    str_list = s
    str_list_encry = str_list
    i = 0
    while i < len(str_list):
        if ord(str_list[i]) < 123-k:
            str_list_encry[i] = chr(ord(str_list[i]) + k)
        else:
            str_list_encry[i] = chr(ord(str_list[i]) + k - 26)
        i = i+1
    return str_list_encry
main()
